/**
 * 深拷贝
 */
export function deepClone<T>(sourceData: T): T {
  if (Array.isArray(sourceData))
    return sourceData.map(item => deepClone(item)) as unknown as T

  const obj: T = {} as T
  for (const key in sourceData) {
    if (typeof sourceData[key] === 'object' && sourceData[key] !== null)
      obj[key] = deepClone(sourceData[key])
    else
      obj[key] = sourceData[key]
  }
  return obj
}
